// 导入自定义路由
// import Home from '@/pages/Home'
import Login from '@/pages/Login'
import Register from '@/pages/Register'
import Search from '@/pages/Search'
import Detail from '@/pages/Detail'
import AddCartSuccess from '@/pages/AddCartSuccess'
import ShopCart from '@/pages/ShopCart'
import Trade from '@/pages/Trade'
import Pay from '@/pages/pay'
import Center from '@/pages/Center'
import MyOrder from '@/pages/Center/myOrder'
import GroupBuy from '@/pages/Center/groupOrder'

export default [
    {
        path: '/communication',
        component: () => import('@/pages/Communication/Communication'),
        children: [
            {
                path: 'attr-listeners',
                component: () => import('@/pages/Communication/AttrsListenersTest/AttrsListenersTest'),
                meta: {
                    isHideFooter: true
                }
            },
            {
                path: 'children-parent',
                component: () => import('@/pages/Communication/ChildrenParentTest/ChildrenParentTest'),
                meta: {
                    isHideFooter: true
                }
            },
            {
                path: 'event',
                // src\pages\Communication\EventTest\EventTest.vue
                component: () => import('@/pages/Communication/EventTest/EventTest'),
                meta: {
                    isHideFooter: true
                }
            },
            {
                path: 'sync',
                component: () => import('@/pages/Communication/SyncTest/SyncTest'),
                meta: {
                    isHideFooter: true
                },
            },
            {
                path: 'scope-slot',
                component: () => import('@/pages/Communication/ScopeSlotTest/ScopeSlotTest'),
                meta: {
                    isHideFooter: true
                },
            }
        ]
    },
    {
        path: '/center',
        component: Center,
        children: [
            {
                path: 'myorder',
                component: MyOrder,
            },
            {
                path: 'groupbuy',
                component: GroupBuy,
            },
            {
                path: '',
                redirect: 'myorder',
            },
        ]
    },
    {
        path: '/pay',
        component: Pay,
        props: route => ({ orderId: route.query.orderId }),
        beforeEnter(to, from, next) {
            if (from.path === '/trade') {
                next()
            } else {
                next('/trade')
            }
        }
    },
    {
        path: '/trade',
        component: Trade,
        beforeEnter(to, from, next) {
            if (from.path === '/shopcart') {
                next()
            } else {
                next('/shopcart')
            }
        }
    },
    {
        path: '/shopcart',
        component: ShopCart,
        meta: {
            isShow: true
        }
    },
    {
        name: 'addcartsuccess',
        path: '/addcartsuccess',
        component: AddCartSuccess,
        meta: {
            isShow: true
        }
    },
    {
        name: 'detail',
        path: '/detail/:skuId?',
        component: Detail,
        meta: {
            isShow: true
        }
    },
    {
        path: '/home',
        component: () => import('@/pages/Home'),
        meta: {
            isShow: true
        }
    }, {
        path: '/login',
        component: Login,
        meta: {
            isShow: false
        }
    }, {
        path: '/register',
        component: Register,
        meta: {
            isShow: false
        }
    }, {
        name: "Search",
        path: '/search/:keyword?',
        component: Search,
        meta: {
            isShow: true
        },
        // props: true
        // props: { a: 1, b: 2 }
        props: ($route) => {

            console.log($route)
            return ({ keyword: $route.params.keyword, k: $route.query.k })
        }
    },
    {
        path: '*',
        redirect: '/home',
        meta: {
            isShow: true
        }
    }
]